<script language="javascript" src="{{$s_path}}/ueditor/ueditor.config.js"></script>
<script language="javascript" src="{{$s_path}}/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="{{$s_path}}/ueditor/lang/zh-cn/zh-cn.js"></script>
 <form method="post" action="admins.php"  name="cat_form">
<article class="module width_full" id="cat_add">
    <header>
      <h3>新增分类</h3>
    </header>
    
    <div class="module_content">
   
      <fieldset>
        <label>分类名称</label>
        <input type="text" value="{{$cat.cat_name}}" name="cat_name">
      </fieldset>
      <fieldset>
        <strong>分类内容</strong>
        <textarea rows="12"  name="cat_content" id="cat_content" style="height:200px">{{$cat.cat_content}}</textarea>
        <script>
          UE.getEditor('cat_content');
        </script>
      </fieldset>
      <fieldset style="width:48%; float:left; margin-right: 3%;">
        <!-- to make two field float next to one another, adjust values accordingly -->
        <label>父分类</label>
        <select style="width:92%;" name="parent_id">
          <option value="">请选择</option>
          {{foreach from=$categories item=list key=key}}
          <option value="{{$list.cat_id}}" {{if $cat.parent_id==$list.cat_id}} selected="selected"{{/if}}>{{$list.cat_name}}</option>
          	 {{foreach from=$list.children item=s_list key=s_key}}
         	 <option value="{{$s_list.cat_id}}" {{if $cat.parent_id==$s_list.cat_id}} selected="selected"{{/if}}>┗{{$s_list.cat_name}}</option>
              {{foreach from=$s_list.children item=ss_list key=ss_key}}
         	 <option value="{{$ss_list.cat_id}}" {{if $cat.parent_id==$s_list.cat_id}} selected="selected"{{/if}}>&nbsp;&nbsp;&nbsp;┗{{$ss_list.cat_name}}</option>
          	  {{/foreach}}
          	{{/foreach}}
          {{/foreach}}
        
        </select>
      </fieldset>
      
      <fieldset style="width:48%; float:right;">
        <!-- to make two field float next to one another, adjust values accordingly -->
        <label>keywords</label>
        <input type="text" style="width:92%;" value="{{$cat.keywords}}" name="keywords">
      </fieldset>
      <fieldset style="width:48%; float:left;;margin-right: 3%;">
        <!-- to make two field float next to one another, adjust values accordingly -->
        <label>title</label>
        <input type="text" style="width:92%;" value="{{$cat.title}}" name="title">
      </fieldset>
      <fieldset style="width:48%; float:left;">
        <!-- to make two field float next to one another, adjust values accordingly -->
        <label>description</label>
        <input type="text" style="width:92%;" value="{{$cat.cat_desc}}" name="cat_desc">
      </fieldset>
      
      <div class="clear"></div>
    </div>
    <footer>
      <div class="submit_link">
        <select name="is_show">
          <option value="1">是否显示?</option>
          <option value="1" {{if $cat.is_show=='1'}} selected="selected"{{/if}}>是</option>
          <option value="0" {{if $cat.is_show=='0'}} selected="selected"{{/if}}>否</option>
        </select>
        <input type="hidden"  value="{{$cat.cat_id}}" name="cat_id">
         <input type="hidden" name="act" value="{{$acts}}"/>
        <input type="submit" value="发布" class="alt_btn" onclick="return AD.articleCatEdit('#cat_add')">
       </div>
    </footer>
  </article>
  </form>
<script>
Admin.prototype.articleCatEdit = function(obj){
	var names = ['cat_name','keywords','cat_desc','is_show','parent_id','cat_id'];
	
	var data = Main.dataValue(obj,names);
	data.cat_content = encodeURIComponent(CKEDITOR.instances.cat_content.getData());
	
	if(data.cat_name)
	{
		$("form[name=cat_form]").submit();
	}
	else
	{
		alert("分类名称必须填写！");	
		return false;
	}
}

</script>